#ifndef SEND_MSG_CALLABLE_H_
#define SEND_MSG_CALLABLE_H_
#include <boost/shared_ptr.hpp>
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/protocol/TDebugProtocol.h>
#include <thrift/transport/TSocket.h>
#include <thrift/transport/TBufferTransports.h>
#include <thrift/transport/THttpClient.h>
#include <thrift/TProcessor.h>
#include <glog/logging.h>
#include "gen-cpp/ChatService.h"
#include "client/RequestQueue.h"
namespace at = apache::thrift;
namespace atp = apache::thrift::protocol;
namespace att = apache::thrift::transport;

namespace client {
  class SendMsgCallable {
 public:
    SendMsgCallable() {
    }
    void operator()() {
      while (true) {
        try {
          boost::function<void ()> req = client::RequestQueue::Instance()->Pop();
          req();
        }
        catch (const att::TTransportException& ttx) {
          LOG(ERROR) << ttx.what();
          break;
        }
        catch (const std::exception& e) {
          LOG(WARNING) << e.what();
          continue;
        }
      }
      LOG(INFO) << "SendMsg thread exit";
  
    }

  };
}
#endif
